import {reqSearchShopList} from '../../api'
import {RECEIVE_SEARCH_SHOP} from '../mutations-types'
import store from '../index'

const state ={
    searchShopList: [],
}

const actions = {
    async getSearchShopInfo({commit, state}, keyword) {
        console.log(keyword)
        const geohash =store.state.msite.latitude + ',' + store.state.msite.longitude
        const result = await reqSearchShopList(keyword, geohash)
        
        if (result.code === 0) {
          const searchshop = result.data
          commit(RECEIVE_SEARCH_SHOP, searchshop)
        }
    },
}

const mutations ={
    [RECEIVE_SEARCH_SHOP](state, searchshop) {
        state.searchShopList = searchshop
    },
}

export default {
    state,
    actions,
    mutations,
}